package redis

import "strconv"

//同步虚拟库存

func SyncGoodsStock(goodsId, stock int) {
	key := "goodsId_" + strconv.Itoa(goodsId)
	for i := 0; i < stock; i++ {
		RedIsDB.RPush(key, goodsId)
	}
}

//获取缓存的库存

func GetGoodsStock(goodsId int) int {

	key := "goodsId_" + strconv.Itoa(goodsId)
	res := int(RedIsDB.LLen(key).Val())
	return res
}
